/******************************************************************************/
/******************************************************************************/
/* Maps                                                                       */
/******************************************************************************/
/******************************************************************************/



/***********************************************************/
/***********************************************************/


*Load Analytical Dataset
use "$LocalData\BartikAnalyticData_2digit.dta", clear

replace gsmall_dep15		= . 			if missing(gSmallFirm15)
replace dsmall_dep_share15	= . 			if missing(gSmallFirm15)

		
sort geography year
merge m:1 geography using "$SourceData\usmap.dta"

xtset, clear



bysort year: quantiles c_i_share_200011 if c_i_share_200011!=., gen(ind11) n(100)
bysort year: quantiles c_i_share_200021 if c_i_share_200021!=., gen(ind21) n(100)
bysort year: quantiles c_i_share_200023 if c_i_share_200023!=., gen(ind23) n(100)
bysort year: quantiles c_i_share_200031 if c_i_share_200031!=., gen(ind31) n(100)
bysort year: quantiles c_i_share_200062 if c_i_share_200062!=., gen(ind62) n(100)

*su c_i_share_2000211 c_i_share_2000213 c_i_share_2000113 c_i_share_2000321 c_i_share_2000238, detail

gen keycounty = cond(max(ind11, ind21, ind23, ind31, ind62)>95,1,0)  if gSmallFirm1!=.

preserve
replace year=2017 if year==.
keep if year==2017
grmap keycounty using "$SourceData\uscntycoord.dta" if STATEFP!="02" & STATEFP!="15" & STATEFP<="56" & year==2017, id(id) fcolor(white gs10) ndfcolor(black) clbreak(-0.5 0.5 1.5) legend(off)
*legend( lab(2 "0") lab(3 "1") lab(1 "No Data"))
graph export "$LocalData\Results\KeyCounty.pdf", replace
graph export "$LocalData\Results\KeyCounty.eps", replace
restore

